Skip to main content
This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

Previous Next

Java recycling...

- NEVER recycle:
  • Session
  • Current Database
  • Agent Context
  • One other I can't remember. STRONGLY suggest the R5/R6 forums for extensive info on recycling.

- Feel free to recycle anything else.

- Recycling is such a nightmare that I don't believe there is such a thing as "too much". For instance, I set *everything* to null as well:

somedoc.recycle();
somedoc=null;

- I make sure to recycle things in "reverse" order, because recycling the parent also recycles the children:

someDoc.recycle();
someDoc=null;
someView.recycle();
someView=null;

If you recycle someView first, and someDoc was pulled from that View, it will automagically recycle someDoc and you won't have a chance to set it to null.

- Never try to recycle a recycled object. For some obtuse reason this throws an Exception - one would expect that recycling an object that's been recycled would do nothing and drive on smartly. That's another reason to see everything to null once recycled, now one can tell what's been recycled and what hasn't with a trivial check against null.

- Also be sure that you are in fact recycling everything. It's insidious and easy to miss things. For instance, Document.replaceItemValue() returns an Item and that must be recycled just like anything else inside a loop. I do this:

somedoc.replaceItemValue("somefield", "somevalue").recycle();

The fly in that ointment is that I can't set the Item to null, and for all I know that caused the leaks I never found.

- Then in the finally, which I also *always* employ in Java Agents, I do this:

if(somedoc!=null) { somedoc.recycle(); somedoc=null; }

Yeah I know the code's exiting and null isn't required. It's a tiny price to pay to be absolutely double-dog sure GC knows I'm done with it. I also know Domino is supposed to "clean up on exit". My experience is that any and all assistance one can render to that process is that much less likely to leak and blow up the server, particularly where thousands upon thousands upon thousands of Domino objects are processed.

- Lastly, if you know Java at all, it's vastly simpler to write a wrapper class to do all this stuff for you than it is to manage recycle in the main code. It's so useful one has to wonder why something akin to this isn't provided out of the box, say as a sample of proper recycling practices, instead of requiring every Java developer on Domino to re-invent the wheel.

- Leaks are a nasty PITA and any level of insurance is well done in my book. If this were C++ I'd be all over it, but in Java it's a horrid can of worms.

Hope this helps...


Feedback response number DGIE8G4KAU created by ~Holly Zekhipisonnivu on 04/20/2011

Server JVM Problems (~Dana Cisfooski... 19.Apr.11)
. . known issue with java agents with a... (~Dean Refanaikl... 20.Apr.11)
. . Check out Notes.ini setting for Jav... (~Arnold Zenjumi... 20.Apr.11)
. . . . That one I am trying to use already... (~Dana Cisfooski... 20.Apr.11)
. . . . . . You *do* recycle all Notes objects ... (~Arnold Zenjumi... 20.Apr.11)
. . . . . . . . Yes, but ....... (~Dana Cisfooski... 20.Apr.11)
. . . . . . . . . . also.... (~Dana Cisfooski... 20.Apr.11)
. . . . . . . . . . . . Java recycling... (~Zelda Ekresask... 20.Apr.11)
. . . . . . . . . . . . . . Tremendous (~Dana Cisfooski... 20.Apr.11)
. . . . . . . . . . . . . . . . Domingo (~Hal Nonboosige... 22.Apr.11)




Printer-friendly

Search this forum

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS